<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>管理</title>
	<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" href="css/bootstrap.min.css" />
	<link rel="shortcut icon" th:href="@{/img/favicon.ico}">
	<script type="text/javascript" th:src="@{/js/jquery-1.11.3.min.js}" src="js/jquery1.12.4.min.js"></script>
	<script type="text/javascript" th:src="@{/js/bootstrap.min.js}" src="js/bootstrap.min.js"></script>
	<script>
		$(function () {
			$("#f1").submit(function () {
				var $realname = $("#realname");
				var $email = $("#email");
				var $telephone = $("#telephone");
				$realname.val($.trim($realname.val()));
				$email.val($.trim($email.val()));
				$telephone.val($.trim($telephone.val()));
			})
			//实现复选框全选 全不选
			$("input[name='choose']").click(function () {
				$(":checkbox[name='ids']").prop("checked",this.checked);
			})
			$("#deleteBatch").click(function () {
				//获取选中的复选框的个数
				var length =$(":checkbox[name='ids']:checked").length;
				//console.log()
				if(length<=0){
					alert("请选中后再删除!!!")
					return;
				}else {
					alert("确定要删除吗？")
					$("#deleteBatchFrom").submit();
				}


			})
		})
	</script>
	<style>
		.lan{
			margin-left: 20px;
		}
	</style>
</head>

<body>
<div class="container-fluid">
	<div class="panel panel-default">
		<div class="panel-heading clearfix">
			<form id="f1" class="form-inline pull-left" method="post" th:action="@{/admin/user/listAll}" action="${pageContext.request.contextPath}/user/list">
				<div class="form-group">
					<label for="realname">真实姓名</label>
					<input type="text" name="name" class="form-control" id="realname"
						   placeholder="真实姓名">
				</div>
				<div class="form-group">
					<label for="email">Email</label>
					<input type="email" name="email" class="form-control" id="email"
						   placeholder="Email">
				</div>
				<div class="form-group">
					<label for="telephone">电话</label>
					<input type="text" name="telephone" class="form-control" id="telephone"
						   placeholder="电话">
				</div>
				<button type="submit" class="form-control">查询</button>
			</form>
			<a href="item-add.html" th:href="@{/admin/user/addUI}"  class="btn btn-primary pull-right lan" >添加用户</a>

			<button type="button" class="btn btn-primary pull-right" id="deleteBatch">删除选中</button>
		</div>
		<form id="deleteBatchFrom" th:action="@{/admin/user/deleteBatch}" method="post">
			<table class="table table-bordered table-hover ">
				<tr class="success">
					<th><input type="checkbox" name="choose"></th>
					<th>编号</th>
					<th>用户名</th>
					<th>密码</th>
					<th>真实姓名</th>
					<th>邮箱</th>
					<th>电话</th>
					<th>操作</th>
				</tr>
				<tr th:each="user:${users}">
					<td><input type="checkbox" name="ids" th:value="${user.uid}" ></td>
					<td th:text="${user.uid}">1</td>
					<td th:text="${user.username}">wc001</td>
					<td th:text="${user.password}">888</td>
					<td th:text="${user.name}">旺财</td>
					<td th:text="${user.email}">2232323@qq.com</td>
					<td th:text="${user.telephone}">13545889112</td>
					<td>
						<a class="btn btn-success btn-sm" th:href="@{/admin/user/updateUI(uid=${user.uid})}" href="">修改</a>&nbsp;
						<a class="btn btn-danger btn-sm" th:href="@{/admin/user/delete(uid=${user.uid})}"  onclick="return confirm('确定删除吗？')" href="">删除</a>
					</td>
				</tr>


			</table>
		</form>
	</div>
</div>
</body>

</html>